package com.ruoyi.ewem.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ewem.domain.Drivers;
import com.ruoyi.ewem.service.IEwemDriversService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 物流司机Controller
 * 
 * @author ruoyi
 * @date 2024-07-27
 */
@RestController
@RequestMapping("/drivers")
public class EwemDriversController extends BaseController
{
    @Autowired
    private IEwemDriversService ewemDriversService;

    /**
     * 查询物流司机列表
     */
    @RequiresPermissions("ewem:drivers:list")
    @GetMapping("/list")
    public TableDataInfo list(Drivers ewemDrivers)
    {
        startPage();
        List<Drivers> list = ewemDriversService.selectEwemDriversList(ewemDrivers);
        return getDataTable(list);
    }

    /**
     * 导出物流司机列表
     */
    @RequiresPermissions("ewem:drivers:export")
    @Log(title = "物流司机", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Drivers ewemDrivers)
    {
        List<Drivers> list = ewemDriversService.selectEwemDriversList(ewemDrivers);
        ExcelUtil<Drivers> util = new ExcelUtil<Drivers>(Drivers.class);
        util.exportExcel(response, list, "物流司机数据");
    }

    /**
     * 获取物流司机详细信息
     */
    @RequiresPermissions("ewem:drivers:query")
    @GetMapping(value = "/{driverId}")
    public AjaxResult getInfo(@PathVariable("driverId") Long driverId)
    {
        return success(ewemDriversService.selectEwemDriversByDriverId(driverId));
    }

    /**
     * 新增物流司机
     */
    @RequiresPermissions("ewem:drivers:add")
    @Log(title = "物流司机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Drivers ewemDrivers)
    {
        return toAjax(ewemDriversService.insertEwemDrivers(ewemDrivers));
    }

    /**
     * 修改物流司机
     */
    @RequiresPermissions("ewem:drivers:edit")
    @Log(title = "物流司机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Drivers ewemDrivers)
    {
        return toAjax(ewemDriversService.updateEwemDrivers(ewemDrivers));
    }

    /**
     * 删除物流司机
     */
    @RequiresPermissions("ewem:drivers:remove")
    @Log(title = "物流司机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{driverIds}")
    public AjaxResult remove(@PathVariable Long[] driverIds)
    {
        return toAjax(ewemDriversService.deleteEwemDriversByDriverIds(driverIds));
    }
}
